package org.server.http.conf;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.task.setter.AbstractSetter;

/**
 * 阻止ip
 * 
 * @author Admin
 * 
 */
public class BlockedIpConfig extends AbstractSetter {

	// 阻止ip集合
	private Set<String> blocked_set = new HashSet<String>();
	private final static BlockedIpConfig instance;
	static {
		instance = new BlockedIpConfig();
	}

	// 返回唯一实例
	public static BlockedIpConfig getInstance() {
		return instance;
	}

	// 私有化构造
	private BlockedIpConfig() {
		super("conf/http-blocked-ip.cnf", "#Blocked ip list..");
	}

	/**
	 * 验证是否阻止
	 * 
	 * @param ip
	 */
	public boolean isBlocked(String ip) {
		return blocked_set.contains(ip);
	}

	@Override
	public void update(Collection<String> list) {
		// TODO Auto-generated method stub
		for (String str : list) {
			// 添加阻止ip
			blocked_set.add(str);
		}
	}

}
